package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.hosp.bean.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.hosp.utils.HttpRequestHelper;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/3/16 17:36
 */
@RestController
@RequestMapping("/api/hosp")
public class ApiScheduleController {
    @Autowired
    private ScheduleService scheduleService;
    @PostMapping("/saveSchedule")
    public Result saveSchedule(HttpServletRequest request){
        scheduleService.saveSchedule(request);
        return Result.ok();
    }
    //分页查询排班信息
    @PostMapping("/schedule/list")
    public Result scheduleList(HttpServletRequest request){
        Map<String, Object> map = HttpRequestHelper.switchRequest(request);
        Page<Schedule> page =scheduleService.scheduleList(map);
        return Result.ok(page);
    }
    //订单模块查询排班信息
    @GetMapping("/schedule/getScheduleOrderVo")
    public ScheduleOrderVo getScheduleOrderVo(@RequestParam("scheduleId") String scheduleId){

        return scheduleService.getScheduleOrderVo(scheduleId);
    }
}
